package queue;

public class Main {
    public static void main(String[] args) {
        MessageQueue messageQueue = new MessageQueue();

        Thread producer = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                Message message = new Message("Message " + i);
                messageQueue.addMessage(message);
            }
        });
        producer.start();

        Thread consumer = new Thread(() -> {
            try {
                while (true) {
                    Message message = messageQueue.getMessage();
                    System.out.println("Received message: " + message.getContent());
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        consumer.start();
    }
}
